<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.prime.com.tr/ui"
	template="/WEB-INF/layouts/content.xhtml">
	<ui:define name="content">
		<h:form id="searchForm">
			<h2>
				<h:outputText value="#{messageSource['search.headline']}"
					class="headline" />
			</h2>
			<div id="searchFormData">
				<table>

					<tr>
						<td class="formtext">#{messageSource['search.from']}</td>
						<td><h:inputText id="from" value="#{searchBean.from}"></h:inputText>
							<h:message for="from"></h:message></td>
					</tr>
					<tr>
						<td  class="formtext">#{messageSource['search.to']}</td>
						<td><h:inputText id="to" value="#{searchBean.to}"></h:inputText>
							<h:message for="to"></h:message></td>
					</tr>
					<tr>
						<td  class="formtext">#{messageSource['search.date']}</td>
						<td><p:calendar locale="#{languageBean.locale}"
								 id="tripDates" value="#{searchBean.tripDate}"></p:calendar>
						</td>
					</tr>
					

				</table>
				<div><p:commandButton  action="submit" value="#{messageSource['search.startSearch']}"/></div>
			</div>
			<p:dataTable value="#{searchBean.results}" var="connection" rendered="#{not empty searchBean.results }"
				id="results">
				<p:column id="date" sortBy="#{connection.tripDate}">
					<f:facet name="header">#{messageSource['search.date']}</f:facet>

					<h:outputText value="#{connection.tripDate}">
						<f:convertDateTime style="date" timeZone="Europe/Berlin"
							locale="#{languageBean.locale}" />
					</h:outputText>
				</p:column>
				<p:column id="from" sortBy="#{connection.from}">
					<f:facet name="header">#{messageSource['search.from']}</f:facet>
					<h:outputText value="#{connection.from}">

					</h:outputText>
				</p:column>
				<p:column id="to" sortBy="#{connection.to}">
					<f:facet name="header">#{messageSource['search.to']}</f:facet>
					<h:outputText value="#{connection.to}">

					</h:outputText>
				</p:column>
				<p:column id="seatsAvailable" sortBy="#{connection.seatsAvailable}">
					<f:facet name="header">#{messageSource['connection.seatsAvailable']}</f:facet>
					<h:outputText value="#{connection.seatsAvailable}">

					</h:outputText>
				</p:column>
				<p:column id="price" sortBy="#{connection.price}">
					<f:facet name="header">#{messageSource['connection.price']}</f:facet>
					<h:outputText value="#{connection.price}">
						<f:convertNumber minFractionDigits="2" maxFractionDigits="2"></f:convertNumber>
					</h:outputText>
				</p:column>
				<p:column id="link" >
					<f:facet name="header"></f:facet>
					<h:commandLink id="Link" action="detail">
					<f:param name="connectionId" value="#{connection.id}"></f:param>
					 Detail
					</h:commandLink>
				</p:column>
			</p:dataTable>
		</h:form>
	</ui:define>
</ui:composition>